Options
All
  • Public
  • Public/Protected
  • All
Menu

Module eiaSteroids

Example project demonstrating object oriented design for the course Entwicklung Interaktiver Anwendungen II (EIA2) https://jirkadelloro.github.io/EIA2-Inverted/

Project heavily inspired by Asteroids, the arcade classic created by Atari https://www.atari.com/

To create this documentation using TypeDoc: typedoc --tsconfig ../../tsconfig.json

author

Jirka Dell'Oro-Friedl

copyright

Jirka Dell'Oro-Friedl, Hochschule Furtwangen University, 2020

Index

Variables

Let asteroidPaths

asteroidPaths: Path2D[]

Let crc2

crc2: CanvasRenderingContext2D

Const frameRate

frameRate: number = 50

Const frameTime

frameTime: number = 1 / frameRate

Let gamestate

gamestate: GAMESTATE

Const linewidth

linewidth: number = 2

Let moveables

moveables: Moveable[] = []

Let shapesAsteroids

shapesAsteroids: number[][][] = [[[30, 1], [50, 15], [71, 1], [88, 31], [67, 40], [84, 63], [59, 93], [30, 79], [19, 87], [2, 63], [15, 43], [8, 20]],[[39, 1], [53, 28], [78, 15], [91, 41], [76, 59], [78, 82], [44, 94], [15, 83], [1, 55], [14, 14]],[[39, 0], [57, 26], [68, 7], [86, 31], [88, 70], [53, 58], [54, 96], [26, 91], [28, 76], [2, 56], [15, 19]],[[37, 3], [70, 14], [62, 34], [83, 31], [78, 76], [55, 96], [20, 84], [7, 67], [5, 27], [20, 15], [39, 39]]]

Let ship

ship: Ship

Let ufoPath

ufoPath: Path2D

Functions

breakAsteroid

  • breakAsteroid(_event: Event): void
  • Marks the asteroid given with the event object as expandable and creates two smaller ones, except the asteroid was a smallest one already

    Parameters

    • _event: Event

    Returns void

chargeLaser

  • chargeLaser(_event: MouseEvent): void
  • Calls the ship to charge laser guns

    Parameters

    • _event: MouseEvent

    Returns void

createAsteroidPaths

  • createAsteroidPaths(_shapes: number[][][]): Path2D[]
  • Parameters

    • _shapes: number[][][]

    Returns Path2D[]

createAsteroids

  • createAsteroids(_nAsteroids: number): void
  • Creates the specified number of asteroids

    Parameters

    • _nAsteroids: number

    Returns void

createPaths

  • createPaths(): void
  • Returns void

createShip

  • createShip(): void
  • Creates the players ship in the center of the canvas

    Returns void

createUfo

  • createUfo(_small?: boolean): void
  • Create a Ufo

    Parameters

    • Default value _small: boolean = false

    Returns void

createUfoPath

  • createUfoPath(): Path2D
  • Returns Path2D

deleteExpandables

  • deleteExpandables(): void
  • Removes all objects marked as expendable from the list of moveables and calls the scorePoint function

    Returns void

getColorCharge

  • getColorCharge(_charge: number, _alpha: number): string
  • Calculates the color for the laser guns, the beams, the hotspot and the meter bar

    Parameters

    • _charge: number
    • _alpha: number

    Returns string

handleCollisions

  • handleCollisions(): void
  • Checks collisions of all moveable objects and calls their hit-methods accordingly

    Returns void

handleKeypress

  • handleKeypress(_event: KeyboardEvent): void
  • Parameters

    • _event: KeyboardEvent

    Returns void

handleLoad

  • handleLoad(_event: Event): void
  • Parameters

    • _event: Event

    Returns void

handleShipShot

  • handleShipShot(_event: Event): void
  • Creates laser beams and a hotspot when ship dispatched the shoot event.

    Parameters

    • _event: Event

    Returns void

handleUfoShot

  • handleUfoShot(_event: Event): void
  • Starts a projectile when a Ufo dispatched the shoot event from the Ufos position

    Parameters

    • _event: Event

    Returns void

mapClientToCanvas

  • mapClientToCanvas(_x: number, _y: number): Vector
  • Map a position on the client (event.clientX / Y) to a position on the canvas

    Parameters

    • _x: number
    • _y: number

    Returns Vector

progress

  • progress(): void
  • Handles gamestate and calculates when to spawn which objects dependend on the current score and the number of currently moving objects.

    Returns void

scorePoints

  • scorePoints(_expended: Moveable): void
  • Scores points for every object destroyed as given in the POINTS enum

    Parameters

    Returns void

setGameState

  • Parameters

    Returns void

setHeading

  • setHeading(_event: MouseEvent): void
  • Direct the ship towards the position given in the event object

    Parameters

    • _event: MouseEvent

    Returns void

shootLaser

  • shootLaser(_event: MouseEvent): void
  • Calls the ship to shoot at the position given with the event object

    Parameters

    • _event: MouseEvent

    Returns void

shootProjectile

  • Creates a projectile at the point given with random heading, moving away a little to protect the source

    Parameters

    Returns void

update

  • update(): void
  • The main update function!

    Returns void

Generated using TypeDoc